<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css之美</title>
    <style>
        div {
            position: relative;
            width: 200px;
            height: 200px;
            background-color: pink;
            margin: 100px auto;
        }

        p {
            position: absolute;
            top: -40px;
            left: 50%;
            margin-left: -20px;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: 20px;
            border-color: transparent transparent red transparent;
            font-size: 0;
            line-height: 0;
        }
    </style>
</head>
<body>
    <div>
        <p></p>
    </div>
</body>
</html>